#ifndef TLS_SOCKET_CONNECTION_H_
#define TLS_SOCKET_CONNECTION_H_

#include "./../write_read_module/buffer.h"
#include "socket_address.h"
#include "socket_connection.h"

#include <cstdint>
#include <memory>
class Loop;
class Description;
class ChannelProtocol;
class TlsSocketOperate;
class SocketChannel;
class TlsSocketChannel;
class TlsSocketConnection : public SocketConnection,
                            public std::enable_shared_from_this<TlsSocketConnection>
{
public:
    explicit TlsSocketConnection(Loop * loop);
    ~TlsSocketConnection() override;
    int  OpenSocket(SocketAddress address, Option option) override;
    int  AsyncConnect(SocketAddress address, Option option) override;
    int  AsyncWrite(const uint8_t * data, int data_size) override;
    int  AsyncRead() override;
    void Close() override;

private:
    Loop * m_loop;
    friend class TlsSocketChannel;
private:
    std::shared_ptr<SocketChannel>  m_channel;
    std::shared_ptr<Description>      m_description;
    std::shared_ptr<TlsSocketOperate> m_tls_socket;
    WriteReadBuffer                   m_read_buffer;
    WriteReadBuffer                   m_write_buffer;
    SocketConnection::Option          m_connection_option;
};

#endif
